package com.zust.java.dao.imp;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.zust.java.bean.Product;
import com.zust.java.dao.ProductDao;
import com.zust.java.util.StmtCode;
import com.zust.java.util.StmtMap;

@Repository
public class ProductDaoImp implements ProductDao {

    @Autowired
    private SqlSession session;
    private String stmt = null;
    
    public List<Product> selectProduct() {
        stmt = StmtMap.getStmt(StmtCode.SELECT_PRODUCT);
        return session.selectList(stmt);
    }

    public Product selectProductById(int id) {
        stmt = StmtMap.getStmt(StmtCode.SELECT_PRODUCT_BY_ID);
        return session.selectOne(stmt, id);
    }

}
